#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>

using namespace std;
class Solution {
public:
    int longestCommonSubsequence(string text1, string text2) {
        int count = 0;
        int m = text1.size();
        int n = text2.size();
        int change_j = 0;
        for (int i = 0; i < m; i++)
        {
            for (int j = change_j; j < n; j++)
            {
                if (text1[i] == text2[j])
                {
                    count++;
                    change_j = j + 1;
                    break;
                }
            }
        }
        return count;
    }
};

int main()
{
    Solution s;
    string s1("oxcpqrsvwf");
    string s2 = "shmtulqrypy";
    printf("%d\n",s.longestCommonSubsequence(s1, s2));
    return 0;
}
